<style>
    /* 根据字数修改 */
    .layui-form-label {
        width: 90px;
    }

    .layui-form-item .layui-input-inline {
        width: 240px;
    }
</style>
<div class="layuimini-container layuimini-page-anim">
    <!-- 用于创建子页面 -->
    <div class="page-create"></div>

    <!-- page-main-create -->
    <!-- 用于显示 隐藏 -->
    <div class="layuimini-main page-main-create">
        <div class="title-row layuimini-title ">
            <div class="title-left">
                <h4><span>请休假审批</span></h4>
            </div>
            <div class="title-right">
                <span class="title-right-text">
                    <button type="button" class="layui-btn  layui-btn-sm layui-btn-primary ml-3" lay-on="add"><i
                            class="layui-icon layui-icon-addition"></i>代申请休假</button>
                </span>
            </div>
        </div>
        <div class="m-df">
            <form class="layui-form" action="" lay-filter="search-form">
                <div class="layui-form-item">
                    <div class="search-box-wrapper">
                        <div class="search-box-body">
                            <div class="layui-inline">
                                <label class="layui-form-label">员工姓名</label>
                                <div class="layui-input-inline">
                                    <input type="text" placeholder="请输入" name="nickname" autocomplete="off"
                                        class="layui-input">
                                </div>
                            </div>

                            <div class="layui-inline">
                                <label class="layui-form-label">岗位</label>
                                <div class="layui-input-inline">
                                    <select class="layui-input" lay-append-to="body" placeholder="请选择"
                                        name="supplierCodes" lay-search>
                                        <option value="1">行政</option>
                                        <option value="2">客户服务部负责人</option>
                                        <option value="3">安全员</option>
                                    </select>
                                </div>
                            </div>
                              <div class="layui-inline">
                                <label class="layui-form-label">时间</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="datePeriodStart" autocomplete="off" id="date_period"
                                        class="layui-input date-input ml-3" placeholder="请选择" />
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">所属网格</label>
                                <div class="layui-input-inline">
                                    <select class="layui-input" lay-append-to="body" placeholder="请选择"
                                        name="supplierCodes" lay-search>
                                        <option value="1">行政</option>
                                        <option value="2">客户服务部负责人</option>
                                        <option value="3">安全员</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">企业编制</label>
                                <div class="layui-input-inline">
                                    <select class="layui-input" lay-append-to="body" placeholder="请选择"
                                        name="supplierCodes" lay-search>
                                        <option value="1">行政</option>
                                        <option value="2">客户服务部负责人</option>
                                        <option value="3">安全员</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">所属组织</label>
                                <div class="layui-input-inline">
                                    <select class="layui-input" lay-append-to="body" placeholder="请选择"
                                        name="supplierCodes" lay-search>
                                        <option value="1">行政</option>
                                        <option value="2">客户服务部负责人</option>
                                        <option value="3">安全员</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="search-box-btns">
                            <div class="switch-wrapper" id="toggleFormBtn">
                                <span>展开</span>
                                <i class="layui-icon layui-icon-down" id="toggleIcon"></i>
                            </div>
                            <button type="submit" class="layui-btn layui-btn-sm" lay-submit
                                lay-filter="data-search-btn">查询</button>
                            <button type="reset" class="layui-btn  layui-btn-sm layui-btn-primary">重置</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
        <div class="section table-stripe">
            <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
        </div>
        <script type="text/html" id="currentTableBar">
            <a class="layui-font-blue mr-3" lay-event="edit">编辑</a>
            <a class="layui-font-red  mr-3" lay-event="delete">删除</a>
        </script>
    </div>
</div>
<script>
    layui.use(['form', 'table', 'tabs', 'miniPage', 'element'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            tabs = layui.tabs,
            laydate = layui.laydate,
            layer = layui.layer,
            util = layui.util,
            element = layui.element,
            miniPage = layui.miniPage;
        /******************** 事件 start ********************/

        util.on('lay-on', {
            //新增
            'add': function () {
                //新增传值
                layui.sessionData('APPROVAL_HOLIDAY_PARAMS', {
                    key: 'dataDto',
                    remove: true,// 删除字段
                });
                layui.sessionData('APPROVAL_HOLIDAY_PARAMS', {
                    key: 'pageType',
                    value: 'add'
                });
                var content = miniPage.getHrefContent('page/workforce/approval/components/approvalHolidayAdd.html');
                var openWH = miniPage.getOpenWidthHeight();
                var index = layer.open({
                    title: '代申请休假',
                    type: 1,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: true,
                    area: ['600px', 'auto'],
                    content: content,
                });
            }
        })
        /******************** 事件 end ********************/

        
        /******************** 渲染组件 start ********************/
        form.render('select'); //刷新select选择框渲染
        
        laydate.render({
                   elem: '#date_period',
                      type: 'month'
               });
        /******************** 渲染组件 end ********************/

        table.render({
            elem: '#currentTableId',
            url: 'api/table.json',
            cols: [[
                { field: 'name', minWidth: 100, title: '姓名' },
                { field: 'sign', minWidth: 100, title: '所属网格' },
                { field: 'score', minWidth: 80, title: '所属组织' },
                { field: 'classify', minWidth: 80, title: '假期类型' },
                { field: 'classify', minWidth: 80, title: '申请类型' },
                { field: 'classify', minWidth: 80, title: '状态' },
                { field: 'dataTime', minWidth: 100, title: '开始时间' },
                { field: 'dataTime', minWidth: 100, title: '结束时间' },
                { field: 'dataTime', minWidth: 100, title: '时长' },
                { title: '操作', minWidth: 100, toolbar: '#currentTableBar', fixed: 'right', align: "center" }
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 10,
            page: true,
            skin: 'grid',
            size: 'lg'
        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            var result = JSON.stringify(data.field);
            layer.alert(result, {
                title: '最终的搜索信息'
            });

            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    searchParams: result
                }
            }, 'data');

            return false;
        });

        /**
         * tool 事件监听
         */
        table.on('tool(currentTableFilter)', function (obj) {
            console.log('tool(currentTableFilter)')
            var data = obj.data;
            console.log('tool(currentTableFilter)====', obj)
            if (obj.event === 'edit') {
                //编辑传值
                layui.sessionData('APPROVAL_HOLIDAY_PARAMS', {
                    key: 'dataDto',
                    value: JSON.stringify(data)
                });
                layui.sessionData('APPROVAL_HOLIDAY_PARAMS', {
                    key: 'pageType',
                    value: 'edit'
                });
                var content = miniPage.getHrefContent('page/workforce/approval/components/approvalHolidayAdd.html');
                var openWH = miniPage.getOpenWidthHeight();
                var index = layer.open({
                    title: '代申请休假编辑',
                    type: 1,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: true,
                    area: ['600px', 'auto'],
                    content: content,
                });
                return false;
            } else if (obj.event === 'delete') {
                layer.confirm('确认删除吗', function (index) {
                    obj.del();
                    layer.close(index);
                });
            }
        });

        // 开启监听 折叠展开事件
        miniPage.listen()

    });
</script>